home *** CD-ROM | disk | FTP | other *** search
- Path: alpha2.csd.uwm.edu!peterk
- From: peterk@alpha2.csd.uwm.edu (Peter J Kleczka)
- Newsgroups: comp.lang.c
- Subject: Weird Results with this code :(
- Date: 2 Apr 1996 06:48:22 GMT
- Organization: Information & Media Technologies, University of Wisconsin - Milwaukee
- Distribution: world
- Message-ID: <4jqijm$jpk@uwm.edu>
- NNTP-Posting-Host: 129.89.169.2
-
-
- Hello
- I am trying to learn C and ran into a little snag.
- I got this "timer/eraser" fragment of code from the book
- "The Beginners Guide to C" which so far is proving to be
- a very good text. I re-wrote just that part of the code
- that doesn't work rather than repost the code from the
- book since that would be naughty of me and might get
- me into copyright-infringement-type-littigation :)
-
- The program is supposed to display
- some digits leave them on the screen for a second or so
- and then erase them. The "bug" is that the program seems
- to jump to the timer-loop BEFORE it prints out the digits.
- Consequently the desired display/delay/erase sequence works
- in the wrong order: delay/display/erase.
-
- thanks in advance for your suggestions
- please respond via email: peterk@csd.uwm.edu
-
-
- /* Display and Erase */
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
-
- void main()
- {
- long now;
- char pause;
-
- now = clock();
- printf ("watch the screen carefully please \n");
- printf("I will print the message: \"123 disappear\"\n");
- printf("then after a short pause\n");
- printf("only the digits \"123\" will disappear\n");
- printf("press return when ready\n");
- scanf ("%c", &pause);
- printf ("123 disappear");
-
- for ( ; clock() - now < CLOCKS_PER_SEC ; ); /* the timer loop */
-
- printf ("\r");
- printf (" ");
-
- }
-